--
-- Author: shunguo.chen
-- Date: 2018-04-12 18:45:32
--
-- PvpLoadingInfo pvp 加载信息

local UserBaseInfo = require("app.public.dao.UserBaseInfo")

local fileName = string.getModeName(...)
local ClassRef = class(fileName)

function ClassRef:ctor(data)
	if data then
		self:init(data)
	end

end

-- message PVPLoadingPlayerInfo{
-- 	base.UserBaseInfo userBaseInfo = 1;//玩家的基本信息
-- 	int32 progress = 2;//进度百分比，100表示已完成
-- }
-- message S2C_PVPLoadingOpen{//开启一个pvploading信息
-- 	repeated PVPLoadingPlayerInfo teamA = 1;//队伍1
-- 	repeated PVPLoadingPlayerInfo teamB = 2;//队伍2
-- 	int32 targetID =3;//目标ID
-- }
function ClassRef:init(data)
	local myUid = UD:getUid()
	local membersA = {}
	local isSelfTeamA = false
	for i,v in ipairs(data.teamA) do
		if not isSelfTeamA and v.userBaseInfo.uid == myUid then
			isSelfTeamA = true
		end
		membersA[i] = {
			baseInfo = UserBaseInfo.new(v.userBaseInfo),
			progress = v.progress
		}
	end

	local membersB = {}
	for i,v in ipairs(data.teamB) do
		membersB[i] = {
			baseInfo = UserBaseInfo.new(v.userBaseInfo),
			progress = v.progress
		}
	end

	local teams
	if isSelfTeamA then
		teams = {membersA, membersB}
	else
		teams = {membersB, membersA}
	end

	self.teams = teams
	self.targetID = data.targetID
end

function ClassRef:getDesc()
	
end

return ClassRef